<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Admin extends CI_Controller {
     function __construct(){
        parent::__construct();
        $this->load->library('generales');
        $this->generales->check_config();
        $this->load->model('config_m');
       }
       
      //index
      public function index(){
          $data['title'] = 'Administracion';
          $data['content'] = $this->load->view('admin/v_admin_index','',TRUE);
          $this->load->view('template/template-admin',$data);
          }
          
      //Configuracion del sistema avisos
      public function config_adv(){
          $data['css']= array('bootstrap/bootstrapSwitch');
          $data['js']= array('vendor/bootstrapSwitch');
          $data['title'] = 'Admin. | Configuración';
          $data_config['mensaje'] = $this->session->flashdata('mensaje');
          $data_config['data_config']= $this->config_m->get_config();
          $data['content'] = $this->load->view('admin/v_config_adv',$data_config,TRUE);
          $this->load->view('template/template-admin',$data);
          }               
          
      public function update_config_adv(){ 
          $id_config = $this->input->post('id');
          $show_adv = $this->input->post('show_adv');
          $show_adress = $this->input->post('show_adress');
          $show_price = $this->input->post('show_price');
          $max_upload_img = $this->input->post('max_upload_img');
          $this->config_m->update_config_adv($id_config,$show_adv,$show_adress,$show_price,$max_upload_img);
          redirect('configuracion-avisos');
          }
     
     //configuracion General     
     public function config_gral(){
          $data['title'] = 'Admin. | Configuración';
          $data_config['mensaje'] = $this->session->flashdata('mensaje');
          $data_config['error'] = $this->session->flashdata('error');
          $data_config['data_config']= $this->config_m->get_config();
          $data['content'] = $this->load->view('admin/v_config_general',$data_config,TRUE);
          $this->load->view('template/template-admin',$data);
          }
          
      public function update_config_gral(){ 
          $id_config = $this->input->post('id');
          $title_site = $this->input->post('title_site');
          $desc_site = $this->input->post('desc_site');
          $dire_site = $this->input->post('dire_site');
          $tel_site = $this->input->post('tel_site');
          $contact_email = $this->input->post('contact_email');

          $this->config_m->update_config_gral($id_config,$title_site,$desc_site,$dire_site,$tel_site,$contact_email);
          redirect('configuracion-general');
          }
}                                               